﻿using System;
using System.Runtime.InteropServices;

namespace Baula.TextGen.ComAndVbeIntegration
{
    [ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IInterfaceTypeDual
    {
        void TheMethod();
        string TheProperty { get; }
    }

    [ComVisible(true)]
    [Guid("2624765D-AD10-44E2-B71F-BB3AD05F7C88")]
    [ClassInterface(ClassInterfaceType.None)]
    public class ClassWithInterfaceTypeDual : IInterfaceTypeDual
    {
        public void TheMethod()
        {
            throw new NotImplementedException();
        }

        public string TheProperty
        {
            get { throw new NotImplementedException(); }
        }
    }

    [ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IInterfaceTypeIUnknown
    {
        void TheMethod();
        string TheProperty { get; }
    }

    [ComVisible(true)]
    [Guid("E57BBC74-1EEC-4518-A1F5-FE521FC39787")]
    [ClassInterface(ClassInterfaceType.None)]
    public class ClassWithInterfaceTypeIUnknown : IInterfaceTypeIUnknown
    {
        public void TheMethod()
        {
            throw new NotImplementedException();
        }

        public string TheProperty
        {
            get { throw new NotImplementedException(); }
        }
    }

    [ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IInterfaceTypeIDispatch
    {
        void TheMethod();
        string TheProperty { get; }
    }

    [ComVisible(true)]
    [Guid("F7DEAE3A-A67B-4065-B5FC-8B50F6DF1E55")]
    [ClassInterface(ClassInterfaceType.None)]
    public class ClassWithInterfaceTypeIDispatch : IInterfaceTypeIDispatch
    {
        public void TheMethod()
        {
            throw new NotImplementedException();
        }

        public string TheProperty
        {
            get { throw new NotImplementedException(); }
        }
    }

    [ComVisible(true)]
    //[Guid("90FF16C8-1DFD-42D4-94F1-590AA9D46459")]
    public interface IComInteropPlayground
    {
        void MethodThrowingSystemException(string message);
        void MethodThrowingArgumentOutOfRangeException(string paramName, object actualValue, string message);
        void MethodThrowingApplicationException();
    }

    [ComVisible(true)]
    [Guid("6B62F0C8-0386-47ED-A870-7CF71A007B6F")]
    [ClassInterface(ClassInterfaceType.None)]
    public class ComInteropPlayground : IComInteropPlayground
    {
        public void MethodThrowingSystemException(string message)
        {
            throw new Exception(message);
        }

        public void MethodThrowingArgumentOutOfRangeException(string paramName, object actualValue, string message)
        {
            throw new ArgumentOutOfRangeException(paramName, actualValue, message);
        }

        public void MethodThrowingApplicationException()
        {
            throw new ApplicationException();
        }
    }
}
